import type { RespDataType } from "@/components/app/sys/pages/login/api"
import { localStore } from 'vendor/utils/T'


export type LoginUserInfo = RespDataType.UserInfo;

export default class LoginUser {
  private storeKey = "login_user"

  set = (info: any) => {
    localStore.set(this.storeKey, info)
  }

  get = (): LoginUserInfo => {
    const info = localStore.get(this.storeKey)

    return info || defaultLoginUserInfo;
  }

  clear = () => {
    localStore.remove(this.storeKey)
  }
}

/**
 * 默认值
 */
const defaultLoginUserInfo: LoginUserInfo = {
  user: {
    id: 0,
    userName: "",
    userNickname: "",
    userPassword: "",
    userSalt: "",
    userStatus: 0,
    isAdmin: 0,
    avatar: "",
    deptId: 0,
    mobile: "",
    birthday: 0,
    userEmail: "",
    sex: 0,
    remark: "",
    address: "",
    describe: "",
    lastLoginIp: "",
    lastLoginTime: "",
    createdAt: "",
    updatedAt: "",
    deletedAt: "",
  },
  isSuperAdmin: false,
  permissions: []
}
